package com.unswift.window.factory;

import java.awt.Color;
import java.awt.Component;

import javax.swing.BorderFactory;
import javax.swing.JSplitPane;
import javax.swing.plaf.basic.BasicSplitPaneDivider;
import javax.swing.plaf.basic.BasicSplitPaneUI;

public final class SplitFactory {

	public static JSplitPane create(int rule, Component left, Component right, int dividerLocation, int dividerSize, boolean border){
		JSplitPane splitPane = new JSplitPane(rule, left, right);
		splitPane.setDividerLocation(dividerLocation);
		if(border){
			splitPane.setBorder(BorderFactory.createLineBorder(new Color(204, 204, 204)));
		}else{
			splitPane.setBorder(BorderFactory.createEmptyBorder());
		}
		BasicSplitPaneDivider divider = ((BasicSplitPaneUI)splitPane.getUI()).getDivider();
		divider.setBackground(new Color(221, 221, 221));
		divider.setBorder(BorderFactory.createEmptyBorder());
		divider.setDividerSize(2);
		return splitPane;
	}
	
	public static void setHeight(JSplitPane split, int height){
		split.setDividerLocation(height);
	}
}
